/**
 *  @file          flags-groups.h
 *  @date          Time-stamp: <2013-12-02 06:32:47, by lyzh>
 *  @brief         
 *  @version       1.0.0
 *  @author        Liangyaozhan
 *                 ivws02@gmail.com
 */

#ifndef __FLAGS_GROUPS_H
#define __FLAGS_GROUPS_H

#include "list.h"

struct group;

struct group_dep
{
    struct list_head  node;
    struct group     *grp;
    char             *name;
};


struct group
{
    struct list_head   node;
    struct list_head   dependence_head;
    
    char              *name;
    char              *path;
    int                argc;
    char             **argv;

    int                merged_argc;
    char             **merged_argv;
};

struct group_list
{
    struct list_head   head;

    // merged of the list
    int                argc;
    char             **argv;
};

const char *find_file( void );

void group_list_init( struct group_list *_this );
void group_list_get_from_file( struct group_list *_this, const char *filename );
void group_list_get( struct group_list *_this, const char *buffer );
void group_list_show( struct group_list *_this );
void group_list_merge( struct group_list *_this );
struct group *group_list_match( struct group_list *_this, const char *haystack );
void group_list_resolve( struct group_list *_this );
void group_list_destroy( struct group_list *_this );

void group_init( struct group *_this );
void group_resolve( struct group *_this, const struct list_head *head );
void group_depart( struct group *_this, const char *str );
void group_show( struct group *_this );
void group_destroy( struct group *_this );



// group_dep
void group_dep_init( struct group_dep *_this );
void group_dep_resolve( struct group_dep *_this, const struct list_head *head );
void group_dep_destroy( struct group_dep *_this );

#endif

